package com.news.controller;

import com.news.entity.News;
import com.news.service.AllInOneService;
import com.news.utils.NewsJSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zslaa
 * @version 1.0
 * @date 2020/2/28 12:18
 * FileName: NewsController
 * @Description:
 */
@RestController
@RequestMapping("/news")
public class NewsController {
    @Autowired
    private AllInOneService allInOneService;

    @GetMapping("/list")
    @ResponseBody
    public NewsJSONResult list(@RequestParam(name = "typeId") String typeId) {
        List<News> newsList = allInOneService.queryAllNewsListByType(typeId);
        return NewsJSONResult.ok(newsList);
    }

    @GetMapping("/detail")
    @ResponseBody
    public NewsJSONResult detail(@RequestParam(name = "newsId") String newsId) {
        News detail = allInOneService.queryNewsDetail(newsId);
        return NewsJSONResult.ok(detail);
    }
}
